const express = require('express'); // 框架
const url = require('url'); // url模块

const response = require('module/response'); // 响应

const router = express.Router(); // 路由

/**
 * 登录
 */
router.post('/login', (req, res, next) => {
  let username = req.body.username;
  let password = req.body.password;
  if (username === 'Bell' && password === 'e10adc3949ba59abbe56e057f20f883e') {
    req.session.username = username;
    let user = {
      username: username
    }
    response(res, user, null);
  } else {
    response(res, null, null, 8001, '用户名或密码错误');
  }
});

module.exports = router;
